﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Infraestruturex.Automata.SPA;
using Infraestruturex.Automata;

namespace UnitTests.Automata
{
    public class SpaceSeparatedTokensProvider : IBasicTokenProvider
    {
        private string input;
        public string Input
        {
            get
            {
                return input;
            }
            set
            {
                input = value;
                tokens = input.Split(new char[] { ' ', '\n', '\t', '\r' }, StringSplitOptions.RemoveEmptyEntries);
                Reset();
            }
        }
        private string[] tokens;
        private int current = 0;

        public SpaceSeparatedTokensProvider()
        {

        }
        public SpaceSeparatedTokensProvider(string input)
        {
            this.Input = input;
        }

        public string PeekNextTokenClass()
        {
            return tokens[current];
        }

        public void ConsumeNextToken()
        {
            current++;
        }

        public bool HasMoreTokens()
        {
            return tokens.Length > current;
        }

        public void Reset()
        {
            current = 0;
        }
    }
}
